var verify_retail_tax_cent = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"T1", "MSG":"","DATA":"","SCRIPTNAME":"verify_retail_tax_cent"}');

/**
 *
 * @param number  输入值
 * @param decimalPlaces  要保留的位数
 * @returns {number}
 */
function roundNumber(number, decimalPlaces) {
    var factor = Math.pow(10, decimalPlaces);
    return Math.round(number * factor) / factor;
}
if (!isNull(retail_tax)) {
    // 使用用户填写税率
    if (!isNull(tax_rate) && tax_rate !== 0) {
        var retail = roundNumber(retail_tax / tax_rate, 2)
        var calculated_retail = roundNumber(retail * tax_rate, 2)
        if (calculated_retail != retail_tax) {
            // 7 次 可以调整出
            for (var i = 1; i <= 7; i++) {
                var adjustPrice = (retail_tax - 0.1 * i).toFixed(2)
                var retail1 = roundNumber(adjustPrice / tax_rate, 2)
                var calculated_retail1 = roundNumber(retail1 * tax_rate, 2)
                if (calculated_retail1 != adjustPrice) {
                    continue
                }
                verify_retail_tax_cent.CODE = 1;
                verify_retail_tax_cent.ACTION = 'remind';
                verify_retail_tax_cent.MSG = '原价格 ' + retail_tax + '有分钱，系统自动调整为' + adjustPrice + '';
                break
            }
        }
    }
    // 使用 系统当前税率;随意取个门店的税率
    if (isNull(tax_rate) && !isNull(iva_tax)) {
        var currentTax = iva_tax
        if (!isNull(currentTax)) {
            var retail = roundNumber(retail_tax / currentTax, 2)
            var calculated_retail = roundNumber(retail * currentTax, 2)
            if (calculated_retail != retail_tax) {
                // 7 次 可以调整出
                for (var i = 1; i <= 7; i++) {
                    var adjustPrice = (retail_tax - 0.1 * i).toFixed(2)
                    var retail1 = roundNumber(adjustPrice / currentTax, 2)
                    var calculated_retail1 = roundNumber(retail1 * currentTax, 2)
                    if (calculated_retail1 != adjustPrice) {
                        continue
                    }
                    verify_retail_tax_cent.CODE = 1;
                    verify_retail_tax_cent.ACTION = 'remind';
                    verify_retail_tax_cent.MSG = '原价格 ' + retail_tax + '有分钱，系统自动调整为' + adjustPrice + '';
                    break
                }
            }
        }
    }
}
JSON.stringify(verify_retail_tax_cent);